n = int(input())
arr = list(map(int,input().split()))

def get_result(arr,n):
    rans={}
    for i in range(n):
        sumv= arr[i]
        if rans.get(sumv) is None:
            rans[sumv] = [[i,i]]
        else:
            rans[sumv].append([i,i])
        for j in range(i+1,n):
            sumv+=arr[j]
            if rans.get(sumv) is None:
                rans[sumv] = [[i,j]]
            else:
                rans[sumv].append([i,j])
        maxv=0
        for sumv in rans.keys():
            maxv= max(maxv,disjoint(rans[sumv]))
        return maxv

def disjoint(rans):
    count=1
    rans.sort(key= lambda x:x[1])
    t = rans[0][1]
    for i in range(len(rans)):
        l,r = rans[i]

        if t< l:
            count+=1
            t=r
    return count


print(get_result(arr,n))